<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>


<body>
    <div id="app">

        姓：<input type="text" v-model="xing"> 名 <input type="text" v-model="ming">  姓名:{{xingMing}}
        <button @click="changeName()">改名卡</button>
    </div>


    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
    <script>
        // Vue 实例 在全局环境，就有了Vue构造函数
        const app = new Vue({
            // 通过el 配置选择器
            el: '#app',
            data: {
                xing: "司马",
                ming: "昭",
                xingming: ""
            },
            methods:{
                changeName(){
                    this.xingMing="貂蝉";
                }
            },
            computed: {
                xingMing: {
                    get() {
                        return this.xing+this.ming
                    },
                    set(value) {
                        console.log(value);
                        this.xing=value.slice(0,1);
                        this.ming=value.slice(1);

                    }
                }


            }
        });
    </script>
</body>

</html>